<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/formvalid.js" charset="utf-8"></script>
        <script type="text/javascript" src="../js/channeltype.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            img.s1{width:100px;border:1px #EFEFEF solid;padding:1px;}
            #panel{width:90%;}
        </style>
    </head>
    <body>

        <div id="panel">
            <form id="add_link_frm" name="add_link_frm">
                <table>
                    <tr>
                        <th colspan="5">添加链接</th>
                    </tr>
                    <tr>
                        <td width="11%" class="r">链接名称：</td>
                        <td width="38%">
                            <input name="title" type="text" id="title" tabindex="1" maxlength="20" valid="required" errmsg="链接名称不能为空!" />* </td>
                        <td width="6%">&nbsp;</td>
                        <td width="19%" rowspan="3">
                            <span class="img1"><img id="img_logopic" src="http://cdn.uuola.cn/img/vcode.jpg" width="100" class="hide"></span> </td>
                        <td width="26%">上传链接图片</td>
                    </tr>
                    <tr>
                        <td class="r">站点地址：</td>
                        <td>
                            <textarea name="siteurl" type="text" id="siteurl" tabindex="2" value="http://" valid="required|isUrl|limit" min="1" max="512" errmsg="站点地址不能为空!|链接地址错误!|字符数控制在512内" style="width:350px;height:100px;"></textarea>* </td>
                        <td>&nbsp;</td>
                        <td><input type="button" name="uploadBtn" id="uploadBtn" value="上传图片" tabindex="5" onclick="TxBox.upload('logopic', '', 'IMG.reset');"></td>
                    </tr>
                    <tr>
                        <td class="r">链接类型：</td>
                        <td>
                            <select name="lktype" id="lktype" tabindex="3">
                                <script type="text/javascript" src="../js/linkcfg.js"></script>
                            </select></td>
                        <td>&nbsp;</td>
                        <td><input type="hidden" name="logopic" id="logopic" value="-"/></td>
                    </tr>
                    <tr>
                        <td class="r">发布状态：</td>
                        <td><label>
                                <input name="pubstate" type="radio" id="pubstate_1" value="1" checked>是</label>
                            <label>
                                <input type="radio" name="pubstate" value="0" id="pubstate_0">否</label></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">权重：</td>
                        <td><input name="weight" type="text" id="weight" tabindex="5" value="" maxlength="8"/></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">分类：</td>
                        <td><script>out_select('channeltype');</script>
                            <span id="ctp_name_path"> 请选择信息类别 </span>
                            <input type="button" value="选择类别" onclick="selectCatelogs();"/> *
                            <input type="hidden" name="cid" id="cid" value="" />
                            <input type="hidden" name="ctp" id="ctp" value=""  valid="required" errmsg="信息分类不能为空!" /></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><input name="submitBtn" type="button" class="button medium orange" id="submitBtn" tabindex="7" value="添加" onclick="LINK.submit();" /></td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>



        <script type="text/javascript">
             var frm = ut.e('add_link_frm');
            initValid(frm);
            var LINK={
                submit:function(){
                    var $rb=$('#submitBtn');
                    if(validator(frm)){
                        $rb.attr('disabled','disabled');
                        $.post('../app/link/make.shtm',ut.getFormData('#add_link_frm'),function(x){
                            var r = $.trim(x);
                            if(r=='ok'){
                                ut.m('添加成功!');
                                ut.reload('?t='+ut.r());
                            }else{
                                ut.m('添加链接失败!'+r);
                                $rb.removeAttr('disabled');
                            }
                        });
                    }   
                }
            };  
            
            function initWeight(){
                $.get('../app/link/query_max_weight.shtm?t='+ut.r(),function(x){
                    $('#weight').val((Number($.trim(x))+1));
                });
            };
   
            function selectCatelogs(){
                TxBox.winpop(300,500,'类目选择', 'catalogs_select_pop.html?channeltype='+$('#channeltype').val());
            };

            function reloadCatData(cid,ctp){
                $('#cid').val(cid);
                $('#ctp').val(ctp);
                $('#ctp_name_path').text(cid+';'+ctp);
                TxBox.closeWinpop();
                loadTags(cid,ctp);
            };
		
            function changeChannelType(){
                $('#ctp_name_path').text('请选择信息类别 ');
                $('#cid').val('');
                $('#ctp').val('');
            };
            
            jQuery(function(){
                $('#channeltype').val('4');
                $('#channeltype').change(function(){
                    changeChannelType();
                    if($('#channeltype').val()!='4'){
                        $('#channeltype').val('4');
                    }
                });
                initWeight();
            });
        </script>
    </body>
</html>
